package com.sy.simpleegg.mvp.presenter

import androidx.lifecycle.LifecycleCoroutineScope
import com.sy.simpleegg.base.BasePresenter
import com.sy.simpleegg.mvp.contract.SupplementContract
import com.sy.simpleegg.mvp.model.SupplementModel
import kotlinx.coroutines.launch

class SupplementPresenter(private val lifecycleCoroutineScope: LifecycleCoroutineScope): BasePresenter<SupplementContract.Model, SupplementContract.View>(), SupplementContract.Presenter {

    override fun createModel(): SupplementContract.Model = SupplementModel()
    override fun getOrder(startDate: String, endDate: String) {
        lifecycleCoroutineScope.launch {
            mView?.loadData(mModel?.getOrder(startDate, endDate)?: mutableListOf())
        }
    }

    override fun setRealAmount(id: Long, realAmount: String) {
        lifecycleCoroutineScope.launch {
            mModel?.setRealAmount(id, realAmount)
        }
    }


}